package gameobjects.enemies
{
	import assets.Globals;
	
	import flash.events.TimerEvent;
	
	import gameobjects.Enemy;
	import gameobjects.InvisibleProjectile;
	import gameobjects.Projectile;

	public class Creep2 extends Enemy
	{
		private var myMovie:Enemy2 = new Enemy2();
		
		public function Creep2()
		{
			super(65, 10, 300);
			
			graphic.addChild(myMovie);
			
			graphic.y = -8;
			
			addChild(graphic);
			
			value = 2;
			
			cs.x = 48;
			cs.y = 85;
			cs.graphics.beginFill(0xFF0000);
			cs.graphics.drawCircle(0, 0, 20);
			cs.graphics.endFill();
			cs.alpha = 0;
			
			addChild(cs);
		}
		
		override public function pause():void
		{
			super.pause();
			myMovie.stop();
		}
		
		override public function resume():void
		{
			super.resume();
			if (isAttacking())
				myTween.pause();
			myMovie.play();
		}
		
		override public function destroy():void
		{
			super.destroy();
			myMovie.die();
		}
		
		override public function move():void
		{
			super.move();
			myMovie.walk();
		}
		
		override public function attack():void
		{
			super.attack();
			myMovie.attack();
		}
		
		override public function timerHandler(event:TimerEvent):void
		{
			var invisible:Projectile = new InvisibleProjectile(this, 3);
			invisible.x = x+46;
			invisible.y = y + 15;
			Globals.game.addChild(invisible);
		}
	}
}